fn main() {
	// arrays can be converted to a string and easily printed
	nums := [1, 2, 3, 4, 5, 6]
	println(nums) // call nums.str() and convert to a string
	
	nums_copy := nums.clone() // copy the data from the array
	
	// arrays can be efficiently filtered and mapped
	// `it` is a builtin variable which refers to the element currently being processed
	even := nums.filter(it % 2 == 0)
	println(even) // [2, 4, 6]
	
	// filter can accept anonymous functions
	even_fn := nums.filter(fn (x int) bool {
		return x % 2 == 0
	})
	println(even_fn)
	
	words := ['hello', 'world']
	upper := words.map(it.to_upper())
	println(upper)
	
	// .any() and .all() can be used to test for elements that satisfy a condition
	println(nums.any(it ==2)) // true
	println(nums.all(it > 2)) // false
}

// built-in methods for arrays
//   a.repeat(n) concatenates the array elements n times
//   a.insert(i, val) inserts a new element val at index i and shifts all following element to the rights
//   a.insert(i, [3, 4, 5]) inserts several elements
//   a.prepend(val) inserts a value at the beginning, equivalent to a.insert(0, val)
//   a.prepend(arr) inserts elements of array arr at the beginning
//   a.trim(new_len) truncates the length (if new_length < a.len, otherwise does nothing)
//   a.clear() empties the array without changing cap (equivalent to a.trim(0))
//   a.delete_many(start, size) removes size consecutive elements from index start – triggers reallocation
//   a.delete(index) equivalent to a.delete_many(index, 1)
//   a.delete_last() removes the last element
//   a.first() equivalent to a[0]
//   a.last() equivalent to a[a.len - 1]
//   a.pop() removes the last element and returns it
//   a.reverse() makes a new array with the elements of a in reverse order
//   a.reverse_in_place() reverses the order of elements in a
//   a.join(joiner) concatenates an array of strings into one string using joiner string as a separator
